package com.woniu.apiBoss.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.apiBoss.service.ApiOrderService;
import com.woniu.internalcommon.dto.ApiBossOrder;
import com.woniu.internalcommon.dto.OrderInfo;
import com.woniu.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zcnovice
 * @data 2025/7/15 上午11:35
 */
@RestController
@RequestMapping("/order")
@CrossOrigin
public class ApiOrderController {
    @Autowired
    private ApiOrderService apiOrderService;

    /**
     * 多条件分页查询 --订单
     */
    @PostMapping("/getAll")
    public ResponseResult<Page<OrderInfo>> getAll(@RequestBody ApiBossOrder apiBossOrder) {
        OrderInfo orderInfo = apiBossOrder.getOrderInfo();
        if (orderInfo.getId()==null ){
            orderInfo.setId(0L);
        }
        if (orderInfo.getPassengerId()==null){
            orderInfo.setPassengerId(0L);
        }
        if (orderInfo.getDriverId()==null){
            orderInfo.setDriverId(0L);
        }
        apiBossOrder.setOrderInfo(orderInfo);
        return apiOrderService.getAll(apiBossOrder);
    }
}
